﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace LearningEnglish.Controllers.Mock
{
    public class MockWordBookController : Controller
    {
        [AcceptExAjax]
        [NormalJson]
        public ActionResult New(string name, string message, string img)
        {
            if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(img))
                throw new Exception("关键值为空");
            return Json(new { id = ZData.WordBookID }, JsonRequestBehavior.AllowGet);
        }

        [AcceptExAjax]
        [NormalJson]
        public ActionResult All()
        {
            var result = new List<dynamic>();
            result.Add(new
            {
                id = ZData.WordBookID,
                name = "神奇书，神奇书，我们都要赞美你，因为你最蛋疼",
                message = "神奇爆菊书。。。。。。菊花心中红胜火，爆得花心一片血",
                status = "哦哦哦，目前你已学习了该书1024个单词，剩余N个单词。谁也不知道你还要学多少个单词，因为这本书没完没了",
                img = ZData.FilePath
            });

            return Json(new { word_books = result }, JsonRequestBehavior.AllowGet);
        }

        [AcceptExAjax]
        [MockCheckToken]
        [NormalJson]
        public ActionResult Add(Guid id, string word)
        {
            return Json(new
            {
                word = word,
                mean = "人之初不知道，知道不，不知道。人二初，有点傻，不知道，知道不。" + (new Random().Next(100000, 10000000).ToString())
            });
        }
    }
}